package lesson.Client;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Revive {
    public static void main(String[] args) throws IOException {
        //1.找码头
        DatagramSocket datagramSocket = new DatagramSocket(10000);

        //2.创建一个新的箱子
        while (true) {
            byte [] b = new byte[1024];
            DatagramPacket dp = new DatagramPacket(b,b.length);

            //3.接收礼物

            datagramSocket.receive(dp);

            //4.获取礼物
            byte [] bytes = dp.getData();
            String s = new String(bytes,0,dp.getLength());
            System.out.println(s);
        }

//        datagramSocket.close();
    }
}
